﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="HtmlExtensions.cs" company="">
//   Copyright (c) 2010/2011 All Right Reserved
// </copyright>
// <summary>
//   Contains HtmlExtensions class declaration.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace IBupro.Extensions
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.Web.Mvc.Html;

    using IBupro.Classes;

    /// <summary>
    /// Various html helpers.
    /// </summary>
    public static class HtmlExtensions
    {
        #region FlashMessenger

        public static void RenderFlashMessengerWidget(this HtmlHelper htmlHelper)
        {
            htmlHelper.RenderAction("Widget", "FlashMessenger");
        }

        #endregion

        #region Translator

        public static string CurrentCulture(this HtmlHelper html)
        {
            return Translator.Instance.Locale;
        }

        public static string Translate(this HtmlHelper htmlHelper, string key)
        {
            return Translator.Instance[key];
        }

        public static string Translate(this HtmlHelper htmlHelper, string key, params object[] args)
        {
            return string.Format(Translator.Instance[key], args);
        }
        #endregion

        #region String TrucateDetail
        public static string TruncateDetail(this HtmlHelper htmlHelper, string text)
        {
            if (text.Length > 50)
                return text.Substring(0, 50) + "...";
            else return text;
        }

        #endregion
    }
}